package com.concerneyes.glasses.view;

import android.content.Context;
import android.webkit.WebView;

import com.concerneyes.R;
import com.concerneyes.mine.TabActivity.serviceCentre.CommonProblem;
import com.concerneyes.mine.adapter.serviceCentre.CommonProblemAdapter;
import com.concerneyes.mine.model.MyServiceCentreModel;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.List;

import common.AbsBaseView;
import http.HttpAsyncTask;
import http.JsonMap;
import http.Url;
import util.ToastHelper;
import util.WebSetting;

public class GlassesAgreementView extends AbsBaseView {
    private WebView wb_rent;
    private Context context;

    public GlassesAgreementView(Context context) {
        super(context);
        this.context = context;
        initView();
    }

    private void initView() {
        wb_rent = (WebView) findViewById(R.id.wb_rent);
    }

    @Override
    public int layoutResId() {
        return R.layout.fragment_glasses_agreement;
    }

    @Override
    public void loadData(Object data) {
        HttpAsyncTask http = new HttpAsyncTask() {

            @Override
            public void onStart(String taskId) {
            }

            @Override
            public void onFinish(String taskId, String response) {
                JsonMap data = JsonMap.parseJson(response);
                if (data == null) {
                    ToastHelper.getInstance()._toast(R.string.network_error_tip);
                    return;
                }
                MyServiceCentreModel models = null;
                if (data.getInt("code") == 200) {
                    String datas = data.getMap("data").toString();
                    try {
                         models = new Gson().fromJson(datas,MyServiceCentreModel.class);
                    } catch (Exception e) {
                    }

                } else {
                    ToastHelper.getInstance()._toast(data.getString("msg"));
                }
                if (models!=null){
                    new WebSetting(wb_rent,context,models.getContent());
                }
            }
        };
        http.setDebug(true);
        http.excute(Url.BaseUrl + "/rental", null, "GET");
    }

    @Override
    public boolean isEmpty() {
        return false;
    }

}
